package renders

import (
	"html/template"
	"net/http"

	"github.com/gin-gonic/gin"
)

// SafeRender 默认不转义标签直接渲染字符串html元素
func SafeRender(r *gin.Engine) {
	r.SetFuncMap(template.FuncMap{
		"safe": func(str string) template.HTML {
			return template.HTML(str)
		},
	})
	r.LoadHTMLFiles("templates/index.tmpl")
	r.GET("/safe-render", func(c *gin.Context) {
		c.HTML(http.StatusOK, "index.tmpl", "<a href='https://liwenzhou.com'>李文周的博客</a>")
	})
}
